package com.cn.cash.baselib.adp;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.cn.cash.baselib.util.ValidatorUtil;

import java.util.List;

public class PagerAdapter extends FragmentPagerAdapter {
    private List<? extends Fragment> fragmentList;
    public PagerAdapter(FragmentManager fm, List<? extends Fragment> fragmentList) {
        super(fm);
        this.fragmentList = fragmentList;
    }

    @Override
    public int getCount() {
        if(ValidatorUtil.isValidList(fragmentList)) {
            return fragmentList.size();
        }else {
            return 0;
        }
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return "";
//        return fragmentList != null && position < fragmentList.size() ? fragmentList.get(position).getTitle() == null ? "" : fragmentList.get(position).getTitle() : "";
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }
}
